Ext.namespace("ChangeSystem");

Ext.define('HIT.view.ExpressSearchWin', {
    extend: 'Ext.window.Window',
    alias: 'widget.expresssearchwin',

    height: 250,
    width: 664,
    overlapHeader: false,
    preventHeader: false,
    title: Share.T('查询'),

    initComponent: function() {
        var me = this;
        this.title = Share.T('查询');        
        Ext.applyIf(me, {
            items: [ {
                xtype: 'panel',
                layout: {
                    type: 'absolute'
                },
                height: 250,
                items: [ {//单据号
                	xtype : 'combobox',
                	x: 20,
                    y: 30,
                    labelWidth: 60,
                    width: 180,
    				triggerAction : 'query',
    				editable : true,
    				queryParam : 'code',//向后台传递输入框中的值
    				minChars : 1,
    				fieldLabel: Share.T('单据号'),
    				emptyText : Share.T('请输入查询条件...'),
     				id:'express-search-sno',
    				valueField : 'value',
    				displayField : 'value',
    				hideTrigger : true, //隐藏下拉箭头  
    				typeAhead : false,
    				queryDelay : 700,
    				queryMode : 'remote',
    				store : new Ext.data.Store({
                    	proxy : {
							type : 'ajax', 
							url : ctx + '/getDealPrintNo',
							params : {},
							reader : {
								type : 'json', 
								totalProperty : '', 
								root : ''
							} 
                    	}, 
						fields : ['value','value'],
						autoLoad : true
                    }),
    				listeners : {
    					expand : function(field, e) {
    						this.store.load();
    					},
    					beforequery : function(e) {
        					var combo = e.combo;   
        					if(!e.forceAll){   
        						var value = e.query;   
        						combo.store.filterBy(function(record,id){   
        							var text = record.get(combo.displayField); 
        							return (text.indexOf(value)!=-1);   
        						});
        						combo.expand();   
        						return false;   
        					}
    					}
    				}
                }, {
                	xtype : 'combobox',
                	x: 205,
                    y: 30,
                    labelWidth: 15,
                    width: 145,
    				triggerAction : 'query',
    				editable : true,
    				queryParam : 'code',//向后台传递输入框中的值
    				minChars : 1,
    				fieldLabel: '~',
     				labelSeparator: ' ',
    				emptyText : Share.T('请输入查询条件...'),
    				selectOnFocus : true,
    				id:'express-search-eno',
    				valueField : 'value',
    				displayField : 'value',
    				hideTrigger : true, //隐藏下拉箭头  
    				typeAhead : false,
    				queryDelay : 700,
    				queryMode : 'remote',
    				store : new Ext.data.Store({
                    	proxy : {
							type : 'ajax', 
							url : ctx + '/getDealPrintNo',
							params : {},
							reader : {
								type : 'json', 
								totalProperty : '', 
								root : ''
							} 
                    	}, 
						fields : ['value','value'],
						autoLoad : true
                    }),
    				listeners : {
    					expand : function(field, e) {
    						this.store.load();
    					},
    					beforequery : function(e) {
        					var combo = e.combo;   
        					if(!e.forceAll){   
        						var value = e.query;   
        						combo.store.filterBy(function(record,id){   
        							var text = record.get(combo.displayField); 
        							return (text.indexOf(value)!=-1);   
        						});
        						combo.expand();   
        						return false;   
        					}
    					}
    				}
                }, {
                	xtype : 'combobox',
                	x: 385,
                    y: 30,
                    width: 225,
    				triggerAction : 'query',
    				editable : true,
    				minChars : 1,
    				fieldLabel: '',
    				multiSelect:true,
    				emptyText : Share.T('请输入查询条件...'),
    	 			id:'express-search-nos',
    				valueField : 'value',
    				displayField : 'value',
    				hideTrigger : true, //隐藏下拉箭头  
    				typeAhead : false,
    				queryDelay : 700,
    				queryMode : 'remote',
    				store : new Ext.data.Store({
                    	proxy : {
							type : 'ajax', 
							url : ctx + '/getDealPrintNo',
							params : {},
							reader : {
								type : 'json', 
								totalProperty : '', 
								root : ''
							} 
                    	}, 
						fields : ['value','value'],
						autoLoad : true
                    }),
    				listeners : {
    					expand : function(field, e) {
    						this.store.load();
    					},
    					beforequery : function(e) {
        					var combo = e.combo;
        					if(!e.forceAll){   
        						var value = e.query;  
        						var arr = value.split(",");
        						var val = arr[arr.length-1];
        						combo.store.filterBy(function(record,id){   
        							var text = record.get(combo.displayField); 
        							return (text.indexOf(val)!=-1);   
        						});
        						combo.expand();   
        						return false;   
        					}
    					}
    				}
                }, {//快递单号
                	xtype : 'combobox',
                	x: 20,
                    y: 65,
                    labelWidth: 60,
                    width: 180,
    				triggerAction : 'query',
    				editable : true,
    				minChars : 1,
    				fieldLabel: Share.T('快递单号'),
    				emptyText : Share.T('请输入查询条件...'),
     		 		id:'express-search-sexpressno',
    				valueField : 'value',
    				displayField : 'value',
    				hideTrigger : true, //隐藏下拉箭头  
    				typeAhead : false,
    				queryDelay : 700,
    				queryMode : 'remote',
    				store : new Ext.data.Store({
                    	proxy : {
							type : 'ajax', 
							url : ctx + '/getDealScanExpressNo',
							params : {},
							reader : {
								type : 'json', 
								totalProperty : '', 
								root : ''
							} 
                    	}, 
						fields : ['value','value'],
						autoLoad : true
                    }),
    				listeners : {
    					expand : function(field, e) {
    						this.store.load();
    					},
    					beforequery : function(e) {
        					var combo = e.combo;   
        					if(!e.forceAll){   
        						var value = e.query;   
        						combo.store.filterBy(function(record,id){   
        							var text = record.get(combo.displayField); 
        							return (text.indexOf(value)!=-1);   
        						});
        						combo.expand();   
        						return false;   
        					}
    					}
    				}
                }, {
                	xtype : 'combobox',
                	x: 205,
                    y: 65,
                    labelWidth: 15,
                    width: 145,
    				triggerAction : 'query',
    				editable : true,
    				minChars : 1,
    				fieldLabel: '~',
     				labelSeparator: ' ',
    				emptyText : Share.T('请输入查询条件...'),
    				selectOnFocus : true,
    	 			id:'express-search-eexpressno',
    				valueField : 'value',
    				displayField : 'value',
    				hideTrigger : true, //隐藏下拉箭头  
    				typeAhead : false,
    				queryDelay : 700,
    				queryMode : 'remote',
    				store : new Ext.data.Store({
                    	proxy : {
							type : 'ajax', 
							url : ctx + '/getDealScanExpressNo',
							params : {},
							reader : {
								type : 'json', 
								totalProperty : '', 
								root : ''
							} 
                    	}, 
						fields : ['value','value'],
						autoLoad : true
                    }),
    				listeners : {
    					expand : function(field, e) {
    						this.store.load();
    					},
    					beforequery : function(e) {
        					var combo = e.combo;   
        					if(!e.forceAll){   
        						var value = e.query;   
        						combo.store.filterBy(function(record,id){   
        							var text = record.get(combo.displayField); 
        							return (text.indexOf(value)!=-1);   
        						});
        						combo.expand();   
        						return false;   
        					}
    					}
    				}
                }, {//日期
                    xtype: 'datefield',
                    x: 20,
                    y: 100,
                    labelWidth:60,
                    width: 180,
                    fieldLabel: Share.T('发票日期'),
                    id:'express-search-sday',
                    editable : false,
                    format		 : 'Y-m-d',
                    msgTarget    : 'side'
                }, {
                    xtype: 'datefield',
                    x: 205,
                    y: 100,
                    labelWidth: 15,
                    width: 145,
                    id:'express-search-eday',
                    editable : false,
                    fieldLabel: '~',
                    labelSeparator: ' ',
                    format:'Y-m-d',
                    msgTarget : 'side'
                }, {
                	xtype : 'combobox', 
                	x: 20,
                    y: 135,
                    labelWidth: 60,
                    width: 330,
    				triggerAction : 'query',
    				editable : true,
    				queryParam : 'code',//向后台传递输入框中的值
    				minChars : 1,
    				fieldLabel : Share.T('客户名称'),
    				emptyText : Share.T('请选择查询条件...'),
    			 	id:'express-search-cust',
    				valueField : 'value',
    				displayField : 'value',
    				hideTrigger : true, //隐藏下拉箭头  
    				typeAhead : false,
    				queryDelay : 700,
    				queryMode : 'remote',
    				store : new Ext.data.Store({
                    	proxy : {
							type : 'ajax', 
							url : ctx + '/getScanCustomList',
							params : {},
							reader : {
								type : 'json', 
								totalProperty : '', 
								root : ''
							} 
                    	}, 
						fields : ['value','value'],
						autoLoad : true
                    }),
    				listeners : {
    					beforequery : function(e) {
        					var combo = e.combo;   
        					if(!e.forceAll){   
        						var value = e.query;   
        						combo.store.filterBy(function(record,id){   
        							var text = record.get(combo.displayField); 
        							return (text.indexOf(value)!=-1);   
        						});
        						combo.expand();   
        						return false;   
        					}
    					}
    				}
                } ]
            } ],
            dockedItems: [ {
                xtype: 'toolbar',
                dock: 'top',
                items: [ {
                    xtype: 'button',
                    width: 65,
                    iconCls: 'tj-tree-file',
                    id  : 'express-search-button',
                    text: Share.T('查询')
                }, {
                    xtype: 'tbfill'
                } ]
            } ]
        });
        me.callParent(arguments);
    }
});
